<?php

//namespace Login\Controller;

require_once '\Views\LoginView.php';
require '\Controllers\RegisterController.php';
require_once '\Controllers\LoginController.php';
require_once '\Models\LoginModel.php';
require_once '\Models\RegisterModel.php';
require_once '\Controllers\IController.php';

class MasterController{
	
	private $m_connection = NULL;
	
	public function __construct(DBConnection $connection)
	{
		$this->m_connection = $connection;
	}
	
	public function CreateController()
	{
		$loginModel = new LoginModel($this->m_connection);
		
		//Skapar loginruta...
		$activeController = new LoginController($loginModel);
		
		//Om man trycker på registera skapa regruta
		$loginView = new LoginView();
		if($loginView->TriedToRegister()){
			$registerModel = new RegisterModel($this->m_connection);
			$activeController = new RegisterController($registerModel);
		}
		
		//Returnera aktiva controllern
		return $activeController->CreateController();
	}
		
}
